﻿package com.gengine.core
{
    import flash.errors.*;
    import flash.events.*;
    import flash.utils.*;

    public class Singleton extends EventDispatcher
    {
        private static var dict:Dictionary = new Dictionary();

        public function Singleton()
        {
            var _loc_1:* = this["constructor"] as Class;
            if (dict[_loc_1])
            {
                throw new IllegalOperationError(getQualifiedClassName(this) + " 只允许实例化一次！");
            }
            dict[_loc_1] = this;
            return;
        }// end function

        public function destory() : void
        {
            var _loc_1:* = this["constructor"] as Class;
            delete dict[_loc_1];
            return;
        }// end function

        public static function getInstance(param1:Class)
        {
            return dict[param1];
        }// end function

        public static function getInstanceOrCreate(param1:Class)
        {
            var _loc_2:* = dict[param1];
            if (_loc_2)
            {
                _loc_2 = new param1;
                dict[param1] = _loc_2;
            }
            return _loc_2;
        }// end function

        public static function create(param1:Class)
        {
            var _loc_2:* = new param1;
            dict[param1] = _loc_2;
            return _loc_2;
        }// end function

    }
}
